package com.example.demo.controller;


import com.example.demo.utils.FileUploadUtil;
import com.example.demo.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/api/upload")
@RequiredArgsConstructor
public class UploadController {

    private final FileUploadUtil uploadUtil;

    @PostMapping
    public Result<List<String>> upload(@RequestPart("files") List<MultipartFile> files) {
        return Result.success(uploadUtil.save(files));
//        return R.ok(uploadUtil.save(files));
    }
}
